#pragma once 
#include <QObject>
#include <QDockWidget>
#include "StarlabPlugin.h"
#include "RichParameterSet.h"
#include "Callbacks.h"
#include "Document.h"
#include "StarlabException.h"
class StarlabDrawArea;

/**
 * @brief The interface of a plugin which gives you total control over the GUI.           
 * @ingroup StarlabPluginInterfaces 
 */
class EditPlugin : public StarlabPlugin {
public: 
    // This will disappear with the new C++ standard
    EditPlugin(){ widget = NULL; isSuspended=false; }
    bool isSuspended;    
    
    /// @{ @name Plugin Creation/Termination
    public:
        /// Called when the user starts the edit the FIRST time (i.e. it does not get re-loaded when the plugin is suspended)
        /// Think about it as a constructor, as the plugin constructor would be automatically loaded at boot time.
        virtual void createEdit(Document* /*doc*/, StarlabDrawArea* /*parent*/)=0;
        /// Called when the user closes the edit
        /// Automatically closes the widget
        /// @todo is suspend a close?
        virtual void destroyEdit(Document* /*doc*/, StarlabDrawArea* /*parent*/)=0;
    /// @} 
    
    /// @{ @name Widget management (optional)
    protected: 
        /// The default (but optionally required) widget of the edit plugin.
        /// If desired, you should instantiate this widget in the overloaded method EditPlugin:createEdit(...)
        QDockWidget* widget;
    public:
        /// Does the plugin make use of a widget?
        bool hasWidget(){ return widget!=NULL; }
        /// Retrieves the widget
        QDockWidget* getWidget(){ assert(widget!=NULL); return widget; }
    /// @}    
    
    /// @{ @name Decorating events (optional)
    public: 
        virtual void Decorate(Document* /*doc*/, StarlabDrawArea* /*parent*/, QPainter* /*p*/){}
    /// @} 

    /// @{ @name User Input Callbacks (optional)
    public: 
        virtual bool mousePressEvent    (QMouseEvent*  /*event*/, Document* /*doc*/, StarlabDrawArea* /*parent*/) { return false; }
        virtual bool mouseMoveEvent     (QMouseEvent*  /*event*/, Document* /*doc*/, StarlabDrawArea* /*parent*/) { return false; }
        virtual bool mouseReleaseEvent  (QMouseEvent*  /*event*/, Document* /*doc*/, StarlabDrawArea* /*parent*/) { return false; }
        virtual bool keyReleaseEvent    (QKeyEvent*    /*event*/, Document* /*doc*/, StarlabDrawArea* /*parent*/) { return false; }
        virtual bool keyPressEvent      (QKeyEvent*    /*event*/, Document* /*doc*/, StarlabDrawArea* /*parent*/) { return false; }
        virtual bool tabletEvent        (QTabletEvent* /*event*/, Document* /*doc*/, StarlabDrawArea* /*parent*/) { return false; }
        virtual bool wheelEvent         (QWheelEvent*  /*event*/, Document* /*doc*/, StarlabDrawArea* /*parent*/) { return false; }
    /// @}
};

Q_DECLARE_INTERFACE(EditPlugin, "starlab.EditPlugin/1.0")
